import pandas as pd

"""
There are two core objects in pandas: the DataFrame and the Series.

DataFrame
A DataFrame is a table. It contains an array of individual entries, 
each of which has a certain value. Each entry corresponds to a row (or record) and a column.

"""
df1 = pd.DataFrame({'Yes': [50, 21], 'No': [131, 2]})
print(df1)

df2 = pd.DataFrame({'Bod': ['i like it', 'it was awful'], 'Rat': [4, 'ddd']})
print(df2)

df3 = pd.DataFrame({'Bob': ['I liked it.', 'It was awful.'], 'Sue': ['Pretty good.', 'Bland.']})
print(df3)

"""
index of dataframe
The dictionary-list constructor assigns values to the column labels, 
but just uses an ascending count from 0 (0, 1, 2, 3, ...) for the row labels. 
Sometimes this is OK, but oftentimes we will want to assign these labels ourselves.

The list of row labels used in a DataFrame is known as an Index. 
We can assign values to it by using an index parameter in our constructor:
"""
df4 = pd.DataFrame({'Bob': ['I liked it.', 'It was awful.'],
                    'Sue': ['Pretty good.', 'Bland.']},
                   index=['Product A', 'Product B'])
print(df4)

"""
Series
A Series, by contrast, is a sequence of data values. 
If a DataFrame is a table, a Series is a list. 
And in fact you can create one with nothing more than a list:
"""
s1 = pd.Series([1, 2, 3, 4, 5])
print(s1)

s2 = pd.Series([30, 35, 40], index=['2015 Sales', '2016 Sales', '2017 Sales'], name='Product A')
print(s2)

"""
a CSV file is a table of values separated by commas. 
Hence the name: "Comma-Separated Values", or CSV.
"""
# 读取数据 额外增加一列index
data_csv_1 = pd.read_csv('../input/melbourne-housing-snapshot/melb_data.csv')
# 行列数
print(data_csv_1.shape)
# 显示前5行
print(data_csv_1.head())
data_csv_2 = pd.read_csv('../input/melbourne-housing-snapshot/melb_data.csv', index_col=0)
print(data_csv_2.head())
